/**
 *	@class			Jx.data.Manager
 *	@description	manages models, records, and datasources
 */
Jx.declare('Jx.data.Manager', {
	
	$singleton: true,
	
	$extend: 'Jx.Base',
	
	$requires: [
		
		'Jx.lib.Hash',
		
		'Jx.data.Collection'
		
	],
	
	$actions: [
		
		'registerModel',
		
		'refreshTable'
		
	],
	
	tables: undefined,
	
	constructor: function(){
		
		this.tables = Jx.instantiate('Jx.lib.Hash');
		
		this.$super(arguments);
		
	},
	
	onRegisterModel: function(operation, modelName){
		
		if (Jx.isFunction(modelName)){
			
			modelName = modelName.$name;
			
		}
		
		this.tables.set(modelName,
			
			Jx.instantiate('Jx.data.Collection')
			
		);
		
	},
	
	onRefreshTable: function(operation){
		
		var rows = operation.table;
		
	},
	
	allowRegisterModel: function(operation, modelName){
		
		return Jx.isClass(modelName, 'Jx.data.Model');
		
	},
	
	allowRefreshTable: function(operation, tableName){

		return !!(operation.table = this.tables.get(tableName));
		
	}
	
	
});
